<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 数据表格</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/account.css" rel="stylesheet">
    <style>
        th ,td{
            text-align: center;
            width:278px;
        }
        #layer-date{
            position: absolute;
            left:-60px;
            top:10px;
            z-index: 1000;
            padding: 0;
            margin-left: 200px;
            margin-top: -5px;
            margin-bottom: -31px;
            border: 0;
            width: 950px;
            float: left;
        }

        #audit{
            width:100px;
            margin-top: 1px;
            float:right;
            margin-right: 10px;
        }
        #name{
            margin-top: 2px;
        }


        #price{
            width: 230px;
        }

        #qq-date{
            margin-left: 30px;
            width: 130px;
            text-align: center;
        }

        .kefu-info {
            float: right;
            font-size: 23px;
            color: red;
            margin-right: 160px;
        }

        #kefu-date{
            width: 100px;
            float: right;
            margin-right: 127px;
            margin-top: -30.4px;
        }

    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    @if(Session::get('MEMBER_INFO')['level'] ==2)
                        <button type="button" id="submit-audit" class="btn btn-primary" data-toggle="modal" data-target="#myModal5">
                            提交审核
                        </button>
                    @endif

                    <form method="post" action="/onlineTeamInfo" role="form" >

                        <div class="form-group" id="layer-date" >
                            <div class="col-sm-5" style="width: 220px;">
                                <input class="form-control layer-date"  name="start_date" value="{{ old('start_date') }}" placeholder="请选择开始时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                            </div>
                            {!! csrf_field() !!}
                            <div class="col-sm-5" style="width: 220px;">
                                <input class="form-control layer-date" name="end_date" value="{{ old('end_date') }}" placeholder="请选择结束时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                            </div>

                            <input type="hidden" name="qq" value="{{ $qq }}">
                            <div class="col-sm-5" style="width: 220px;">
                                <input class="form-control" id="name" name="username" value="{{ old('username') }}" placeholder="请选择用户名" >
                            </div>

                            <div class="col-sm-5" style="width: 100px;">
                                <select id="audit" class="form-control"  name="audit">
                                    <option  value="2">已审核</option>
                                    <option  value="1">未审核</option>
                                    <option  value="3">待审核</option>
                                    <option selected value="4">全部</option>
                                </select>
                            </div>
                            <button class="btn btn-primary" style="margin-left: 15px; margin-top: 1px;" type="submit">查询</button>
                        </div>
                    </form>
                </div>
                <div class="ibox-content">

                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            @if(Session::get('MEMBER_INFO')['level'] ==2)
                            <th style="width:10px;"><input type="checkbox" onclick="selectAll()"></th>
                            @endif
                            <th style="">ID</th>
                            <th>QQ</th>
                            <th>访问时间</th>
                            <th>金额</th>
                            <th>状态</th>
                            <th>IP</th>
                            {{--@if(Session::get('MEMBER_INFO')['level'] !=2)--}}
                                    <th>操作</th>
                            {{--@endif--}}
                        </tr>
                        </thead>
                        <tbody>
                        @if(!empty($data))
                            @foreach($data as $key=>$value)
                                <tr class="gradeX">
                                    @if(Session::get('MEMBER_INFO')['level'] ==2)
                                    <td style="width:10px;"><input name="check-box" type="checkbox"></td>
                                    @endif
                                    <td style="display: none;">{{$value['id']}}</td>
                                    <td style="">{{ $key+1 }}</td>
                                    <td>{{$value['name']}}</td>
                                    <td>{{$value['created_at']}}</td>
                                    <td>{{$value['price']}}</td>
                                    <td>{{$value['audit_name']}}</td>
                                    <td>{{$value['ip']}}</td>
                                    <td>
                                        @if(Session::get('MEMBER_INFO')['level'] !=2)
                                            <button type="button" data-qq="{{$value['qq']}}" {{ $value['audit'] > 1 ?'disabled':'' }} data-id="{{$value['id']}}" data-time="{{$value['created_at']}}" class="btn btn-primary add-audit" data-toggle="modal" data-target="#myModal4">
                                                编辑
                                            </button>
                                        @else
                                            <button type="button" data-qq="{{$value['qq']}}"  data-id="{{$value['id']}}" data-time="{{$value['created_at']}}" class="btn btn-primary audit-delete" data-toggle="modal">
                                                删除
                                            </button>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                        @else
                            <tfoot>
                                <tr>
                                    <th colspan="5">还没有任何信息哦！</th>
                                </tr>
                            </tfoot>
                        @endif
                    </table>
                    {!! $data->appends([
                        'start_date' => isset($where['start_date']) == 1 ? $where['start_date'] :'' ,
                        'end_date' => isset($where['end_date']) == 1 ? $where['end_date'] :'',
                        'username' =>isset($where['username']) ==1 ? $where['username']:'',
                        'qq' =>$qq,
                    ])->render() !!}
                </div>
                <div class="kefu-info">金额：&nbsp;&nbsp;<span>{{$res['money']}}</span></div>
                <div class="kefu-info">用户总量：&nbsp;&nbsp;<span>{{ $res['total_count']}}</span></div>
                <div class="kefu-info">成交用户：&nbsp;&nbsp;<span>{{ $res['num']}}</span></div>
                <div class="kefu-info">成交率：&nbsp;&nbsp;<span>{{ $res['turnover_ratio']}}%</span></div>
                <div class="kefu-info">IP：&nbsp;&nbsp;<span>{{ $res['ip_num']}}</span></div>
            </div>
        </div>
    </div>
</div>

<div class="modal inmodal" id="myModal4" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">提交审核</h4>
            </div>
            <div class="modal-body">

                <form class="form-horizontal" method="post" autocomplete="on"  action="/add/audit">
                    {{--addAccount--}}
                    <div  class="form-group">
                        <label style="margin-left: 40px;" class="col-sm-3 control-label">用户QQ：</label>
                        <div class="col-sm-8">
                            <input type="text" id="name" name="name" value="" autocomplete="new-password" placeholder="用户QQ"  class="form-control">
                        </div>
                    </div>


                    <div style="margin-top: 3px;" class="form-group" >
                        <label style="margin-left: 40px;" class="col-sm-3 control-label">成单：</label>
                        <div class="col-sm-8">
                            <input type="radio"  name="bargain" value="1"  id="bargain1">是  &nbsp;  &nbsp;
                            <input type="radio" name="bargain" value="0" id="bargain2">否&nbsp;&nbsp;

                        </div>
                    </div>
                    <div id="bargain-pirce" class="form-group">
                        <label style="margin-left: 40px;" class="col-sm-3 control-label">金额：</label>
                        <div class="col-sm-8">
                            <input type="text"  id="price" name="price" value="" autocomplete="new-password"  class="form-control">
                        </div>
                    </div>

                    {{--<div id="bargain-date" class="input-group">--}}
                        {{--<span style="float: left;margin-top: 6px;font-size: 14px;margin-left: 110px;">天数：</span>--}}
                        {{--<input type="text" data-oval=""  autocomplete="new-password" id="qq-date"  name="date-num" class="form-control" value="">--}}
                    {{--</div>--}}
                    {{--<div id="kefu-date">--}}
                        {{--<select style="float:right;" id="" class="form-control" name="date">--}}
                            {{--<option  value="1">日</option >--}}
                            {{--<option  value="7">周</option>--}}
                            {{--<option  value="30">月</option>--}}
                        {{--</select>--}}
                    {{--</div>--}}
                    <input type="hidden" id="hidden-qq" name="qq" value="">
                    <input type="hidden" id="hidden-time" name="created_at" value="">
                    <input type="hidden" id="hidden-id" name="id" value="">
                    <br><br>
                    {!! csrf_field() !!}
                    <div class="modal-footer">
                        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<script>
    var qq = {{ $qq }}
</script>
</body>





<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>



<script src="/js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
{{--<script src="/js/content.js?v=1.0.0"></script>--}}
<script src="/js/onlineteam.js"></script>


<script src="js/plugins/layer/laydate/laydate.js"></script>

<!-- Page-Level Scripts -->
<script>

    function selectAll(){
        $("input[type='checkbox']").each( function() {
            if($(this).prop("checked")==true) {
                $("input[type='checkbox']").prop('checked', true);
                return;

            } else {
                $("input[type='checkbox']").prop('checked', false);
                return;
            }
        });
    }




    $('#submit-audit').click(function(){
        var id='';
        if($("input[name='check-box']:checked").length > 0)
        {

            $("input[name='check-box']:checked").each( function() {

                if($(this).parent().next().next().next().next().next().next().text() == '待审核')
                {
                    id = $(this).parent().next().text()+','+id;
                }
            });

            if(confirm('信息审核,请谨慎操作')) {
                $.ajax({
                    url: '/submit/audit',          //  删除账号
                    type: 'get',
                    data: {
                        id: id
                    },
                    timeout: 5000,
                    dataType: 'json',
                    success: function (data, textStatus, jqXHR) {
                        if (data.error_code == 0) {
                            alert('审核成功');
                            self.location='/onlineTeamInfo?qq='+qq;
                        } else {
                            alert(data.error_message);
                        }
                    }
                })

            }


        }else{
            alert("你还没选中什么！");
        }
    });



    $('.audit-delete').click(function(){

    var id= $(this).attr('data-id');
    var qq= $(this).attr('data-qq');
    var time= $(this).attr('data-time');

    var $_this =  $(this);

    if(confirm('信息删除,请谨慎操作')) {
        $.ajax({
            url: '/audit/delete',          //  删除账号
            type: 'get',
            data: {
                id: id,
                qq: qq,
                created_at:time
            },
            timeout: 5000,
            dataType: 'json',
            success: function (data, textStatus, jqXHR) {
                if (data.error_code == 0) {

                    $_this.parent().parent().remove();
                    alert('审核成功');
                } else {
                    alert(data.error_message);
                }
            }
        })

    }



});



    $(document).ready(function () {
        $('.dataTables-example').dataTable();

        /* Init DataTables */
        var oTable = $('#editable').dataTable();

        /* Apply the jEditable handlers to the table */
        oTable.$('td').editable('../example_ajax.php', {
            "callback": function (sValue, y) {
                var aPos = oTable.fnGetPosition(this);
                oTable.fnUpdate(sValue, aPos[0], aPos[1]);
            },
            "submitdata": function (value, settings) {
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTable.fnGetPosition(this)[2]
                };
            },

            "width": "90%",
            "height": "100%"
        });


    });

    function fnClickAddRow() {
        $('#editable').dataTable().fnAddData([
            "Custom row",
            "New row",
            "New row",
            "New row",
            "New row"]);

    }
</script>




</body>

</html>
